﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.ComponentModel;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using ScrumTable.BL.DM.DataManagement;
using ScrumTable.BL.DM.DataManagement.Tracking;
using ScrumTable.Common.Collections;
using ScrumTable.Common.Monitoring;
using ScrumTable.Common.Security;
using ScrumTable.Common.Threading;
using ScrumTable.DL.Data;
using ScrumTable.DL.Data.Common;
using ScrumTable.DL.Data.Local;
using ScrumTable.DL.Data.Local.Test;

#endregion

namespace ScrumTable.BL.DM.Test.DataManagement.Tracking
{
    /// <summary>
    /// This is the test class for UndoManager class.
    /// </summary>
    [TestClass]
    public class UndoManagerTest
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        private IDomainContext _context;

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        #endregion

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates a new UndoManagerTest instance.
        /// </summary>
        public UndoManagerTest()
        {
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        [TestMethod]
        public void TestInit()
        {
            Assert.IsNotNull(_context.UndoManager);
            Assert.IsFalse(_context.UndoManager.CanUndo);
            Assert.IsFalse(_context.UndoManager.CanRedo);
            Assert.IsTrue(_context.UndoManager.Limit > 0);
        }

        [TestMethod]
        public void TestUndo()
        {
            string newValue = Guid.NewGuid().ToString("N");
            string oldValue = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description;

            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = newValue;
            Assert.AreEqual(newValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
            
            Assert.IsNotNull(_context.UndoManager.UndoStack);
            Assert.IsNotNull(_context.UndoManager.UndoStack.First());
            Assert.IsNotNull(_context.UndoManager.UndoStack.First().ElementName);
            Assert.AreEqual(
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name,
                _context.UndoManager.UndoStack.First().ElementName);

            Assert.IsTrue(_context.UndoManager.CanUndo);
            _context.UndoManager.Undo();
            Assert.IsTrue(_context.UndoManager.CanRedo);
            Assert.IsFalse(_context.UndoManager.CanUndo);

            Assert.IsNotNull(_context.UndoManager.RedoStack);
            Assert.IsNotNull(_context.UndoManager.RedoStack.First());
            Assert.IsNotNull(_context.UndoManager.RedoStack.First().ElementName);
            Assert.AreEqual(
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name,
                _context.UndoManager.RedoStack.First().ElementName);

            Assert.AreEqual(oldValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
        }

        [TestMethod]
        public void TestUndoRedoEvents()
        {
            string newValue = Guid.NewGuid().ToString("N");

            bool undoChanged = false;
            bool redoChanged = false;
            bool redoStackChanged = false;
            bool undoStackChanged = false;

            PropertyChangedEventHandler undoHandler =(sender, e) =>
            {
                if (e.PropertyName == "CanUndo")
                    undoChanged = true;
                if (e.PropertyName == "CanRedo")
                    redoChanged = true;
                if (e.PropertyName == "UndoStack")
                    undoStackChanged = true;
                if (e.PropertyName == "RedoStack")
                    redoStackChanged = true;
            };

            Assert.IsFalse(_context.UndoManager.CanUndo);
            Assert.IsFalse(_context.UndoManager.CanRedo);

            try
            {
                _context.UndoManager.PropertyChanged += undoHandler;
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = newValue;

                Assert.IsFalse(redoStackChanged);
                Assert.IsTrue(undoStackChanged);
                Assert.IsTrue(undoChanged);
                Assert.IsFalse(redoChanged);

                undoChanged = false;
                redoChanged = false;
                redoStackChanged = false;
                undoStackChanged = false;

                _context.UndoManager.Undo();
                Assert.IsTrue(undoChanged);
                Assert.IsTrue(redoChanged);
                Assert.IsTrue(redoStackChanged);
                Assert.IsTrue(undoStackChanged);
            }
            finally
            {
                _context.UndoManager.PropertyChanged -= undoHandler;
            }
        }

        [TestMethod]
        public void TestUndoRedoStack()
        {
            Assert.IsNotNull(_context.UndoManager.UndoStack);
            Assert.IsNotNull(_context.UndoManager.RedoStack);

            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = Guid.NewGuid().ToString("N");

            Assert.IsTrue(_context.UndoManager.UndoStack.Count == 1);
            Assert.IsTrue(_context.UndoManager.RedoStack.Count == 0);

            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name = Guid.NewGuid().ToString("N");
            Assert.IsTrue(_context.UndoManager.UndoStack.Count == 2);
            Assert.IsTrue(_context.UndoManager.RedoStack.Count == 0);

            _context.UndoManager.Undo();
            Assert.IsTrue(_context.UndoManager.RedoStack.Count == 1);
            Assert.IsTrue(_context.UndoManager.UndoStack.Count == 1);

            _context.UndoManager.Redo();
            Assert.IsTrue(_context.UndoManager.UndoStack.Count == 2);
            Assert.IsTrue(_context.UndoManager.RedoStack.Count == 0);

            _context.UndoManager.Undo();
            _context.UndoManager.Undo();
            Assert.IsTrue(_context.UndoManager.RedoStack.Count == 2);
            Assert.IsTrue(_context.UndoManager.UndoStack.Count == 0);
        }

        [TestMethod]
        public void TestPropertyEvents()
        {
            string newValue = Guid.NewGuid().ToString("N");
            bool descriptionChanged = false;


            PropertyChangedEventHandler propertyChangedHandler = (sender, e) =>
            {
                if (e.PropertyName == "Description")
                    descriptionChanged = true;
            };

            try
            {
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].PropertyChanged += propertyChangedHandler;
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = newValue;
                Assert.IsTrue(descriptionChanged);
                descriptionChanged = false;

                _context.UndoManager.Undo();
                Assert.IsTrue(descriptionChanged);
                descriptionChanged = false;

                _context.UndoManager.Redo();
                Assert.IsTrue(descriptionChanged);
            }
            finally
            {
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].PropertyChanged -= propertyChangedHandler;
            }
        }

        [TestMethod]
        public void TestCollectionMoveItemUndoRedo()
        {
            UserStory oldStory = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id];
            UserStory newStory = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory4Id];

            Task toMove = oldStory.Tasks[Resources.Task1Id];
            Assert.AreEqual(toMove.IdChain, Resources.FullTask1IdChain);

            newStory.Tasks.Add(toMove);
            Assert.AreEqual(toMove.IdChain, new ValueChain<string>(newStory.IdChain, toMove.Id));
            Assert.IsNotNull(_context.UndoManager.UndoStack);
            Assert.IsNotNull(_context.UndoManager.UndoStack.First());
            Assert.IsNotNull(_context.UndoManager.UndoStack.First().ElementName);
            Assert.AreEqual(toMove.Name, _context.UndoManager.UndoStack.First().ElementName);

            _context.UndoManager.Undo();
            Assert.AreEqual(toMove.IdChain, Resources.FullTask1IdChain);
            Assert.IsNotNull(_context.UndoManager.RedoStack);
            Assert.IsNotNull(_context.UndoManager.RedoStack.First());
            Assert.IsNotNull(_context.UndoManager.RedoStack.First().ElementName);
            Assert.AreEqual(toMove.Name, _context.UndoManager.RedoStack.First().ElementName);

            _context.UndoManager.Redo();
            Assert.AreEqual(toMove.IdChain, new ValueChain<string>(newStory.IdChain, toMove.Id));
        }

        [TestMethod]
        public void TestCollectionMoveEvents()
        {
            UserStory oldStory = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id];
            UserStory newStory = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory4Id];
            bool oldStoryMoveEventRaised = false;
            bool oldStoryAddEventRaised = false;
            bool newStoryMoveEventRaised = false;
            bool newStoryAddEventRaised = false;

            DomainCollectionChangedEventHandler oldStoryEvents = (sender, e) =>
                                                                     {
                                                                         if (e.Action == DomainCollectionChangedAction.Move)
                                                                             oldStoryMoveEventRaised = true;
                                                                         if (e.Action == DomainCollectionChangedAction.Add)
                                                                             oldStoryAddEventRaised = true;
                                                                     };

            DomainCollectionChangedEventHandler newStoryEvents = (sender, e) =>
                                                                     {
                                                                         if (e.Action == DomainCollectionChangedAction.Move)
                                                                            newStoryMoveEventRaised = true;
                                                                         if (e.Action == DomainCollectionChangedAction.Add)
                                                                            newStoryAddEventRaised = true;
                                                                     };

            oldStory.Tasks.CollectionChanged += oldStoryEvents;
            newStory.Tasks.CollectionChanged += newStoryEvents;

            Task toMove = oldStory.Tasks[Resources.Task1Id];

            newStory.Tasks.Add(toMove);
            Assert.IsTrue(oldStoryMoveEventRaised);
            Assert.IsFalse(oldStoryAddEventRaised);
            Assert.IsFalse(newStoryMoveEventRaised);
            Assert.IsTrue(newStoryAddEventRaised);
            oldStoryMoveEventRaised = false;
            oldStoryAddEventRaised = false;
            newStoryMoveEventRaised = false;
            newStoryAddEventRaised = false;

            _context.UndoManager.Undo();
            Assert.IsFalse(oldStoryMoveEventRaised);
            Assert.IsTrue(oldStoryAddEventRaised);
            Assert.IsTrue(newStoryMoveEventRaised);
            Assert.IsFalse(newStoryAddEventRaised);
            oldStoryMoveEventRaised = false;
            oldStoryAddEventRaised = false;
            newStoryMoveEventRaised = false;
            newStoryAddEventRaised = false;

            _context.UndoManager.Redo();
            Assert.IsTrue(oldStoryMoveEventRaised);
            Assert.IsFalse(oldStoryAddEventRaised);
            Assert.IsFalse(newStoryMoveEventRaised);
            Assert.IsTrue(newStoryAddEventRaised);
        }

        [TestMethod]
        public void TestRedo()
        {
            string newValue = Guid.NewGuid().ToString("N");

            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = newValue;
            _context.UndoManager.Undo();
            _context.UndoManager.Redo();
            Assert.IsTrue(_context.UndoManager.CanUndo);
            Assert.IsFalse(_context.UndoManager.CanRedo);
            Assert.AreEqual(newValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
        }

        [TestMethod]
        public void TestUndoWithRedoReset()
        {
            string newValue = Guid.NewGuid().ToString("N");
            string oldValue = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description;

            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = newValue;
            _context.UndoManager.Undo();
            Assert.IsTrue(_context.UndoManager.CanRedo);
            Assert.IsFalse(_context.UndoManager.CanUndo);
            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = oldValue;
            Assert.IsFalse(_context.UndoManager.CanRedo);
            Assert.IsTrue(_context.UndoManager.CanUndo);
            Assert.AreEqual(oldValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
        }

        [TestMethod]
        public void TestMultipleUndo()
        {
            string newDescValue = Guid.NewGuid().ToString("N");
            string newNameValue = Guid.NewGuid().ToString("N");
            double? newRankValue = 12.98;
            string oldDescValue = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description;
            string oldNameValue = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name;
            double? oldRankValue = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Ranking;

            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = newDescValue;
            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name = newNameValue;
            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Ranking = newRankValue;
            Assert.AreEqual(newDescValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
            Assert.AreEqual(newNameValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name);
            Assert.AreEqual(newRankValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Ranking);
            Assert.IsFalse(_context.UndoManager.CanRedo);
            Assert.IsTrue(_context.UndoManager.CanUndo);

            _context.UndoManager.Undo();
            Assert.IsTrue(_context.UndoManager.CanRedo);
            Assert.IsTrue(_context.UndoManager.CanUndo);
            Assert.AreEqual(newDescValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
            Assert.AreEqual(newNameValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name);
            Assert.AreEqual(oldRankValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Ranking);

            _context.UndoManager.Undo();
            Assert.IsTrue(_context.UndoManager.CanUndo);
            Assert.IsTrue(_context.UndoManager.CanRedo);
            Assert.AreEqual(newDescValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
            Assert.AreEqual(oldNameValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name);
            Assert.AreEqual(oldRankValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Ranking);

            _context.UndoManager.Undo();
            Assert.IsFalse(_context.UndoManager.CanUndo);
            Assert.IsTrue(_context.UndoManager.CanRedo);
            Assert.AreEqual(oldDescValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
            Assert.AreEqual(oldNameValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name);
            Assert.AreEqual(oldRankValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Ranking);
        }

        [TestMethod]
        public void TestLimit()
        {
            _context.UndoManager.Limit = 1;
            Assert.IsFalse(_context.UndoManager.CanRedo);
            Assert.IsFalse(_context.UndoManager.CanUndo);

            string oldNameValue = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name;
            string newDescValue = Guid.NewGuid().ToString("N");
            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = newDescValue;
            _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name = Guid.NewGuid().ToString("N"); // overwrites first undo entry

            Assert.IsFalse(_context.UndoManager.CanRedo);
            Assert.IsTrue(_context.UndoManager.CanUndo);

            _context.UndoManager.Undo();
            Assert.IsTrue(_context.UndoManager.CanRedo);
            Assert.IsFalse(_context.UndoManager.CanUndo);
            Assert.AreEqual(oldNameValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name);
            Assert.AreEqual(newDescValue, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
        }

        [TestMethod]
        public void TestCaptureUndoRedoAction()
        {
            string undoRedoElementTop = Guid.NewGuid().ToString("N");
            string undoRedoElementMiddle = Guid.NewGuid().ToString("N");
            string undoRedoElementBottom = Guid.NewGuid().ToString("N");

            string descBefore = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description;
            string nameBefore = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name;

            bool undoRedoBeforeCalledTop = false;
            bool undoRedoAfterCalledTop = false;

            bool undoRedoBeforeCalledMiddle = false;
            bool undoRedoAfterCalledMiddle = false;

            bool undoRedoBeforeCalledBottom = false;
            bool undoRedoAfterCalledBottom = false;

            using (_context.UndoManager.CaptureUndoRedoAction(
                undoRedoElementTop,
                () => undoRedoBeforeCalledTop = true,
                () => undoRedoAfterCalledTop = true))
            {
                using (_context.UndoManager.CaptureUndoRedoAction(
                    undoRedoElementMiddle,
                    () => undoRedoBeforeCalledMiddle = true,
                    () => undoRedoAfterCalledMiddle = true))
                {
                    using (_context.UndoManager.CaptureUndoRedoAction(
                        undoRedoElementBottom,
                        () => undoRedoBeforeCalledBottom = true,
                        () => undoRedoAfterCalledBottom = true))
                    {
                        _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = undoRedoElementTop;
                        _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name = undoRedoElementTop;
                        Assert.AreEqual(0, _context.UndoManager.UndoStack.Count);
                        Assert.AreEqual(0, _context.UndoManager.RedoStack.Count);
                    }

                    _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = undoRedoElementMiddle;
                    _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name = undoRedoElementMiddle;
                    Assert.AreEqual(0, _context.UndoManager.UndoStack.Count);
                    Assert.AreEqual(0, _context.UndoManager.RedoStack.Count);
                }

                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = undoRedoElementBottom;
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name = undoRedoElementBottom;
                Assert.AreEqual(0, _context.UndoManager.UndoStack.Count);
                Assert.AreEqual(0, _context.UndoManager.RedoStack.Count);
            }

            Assert.AreEqual(1, _context.UndoManager.UndoStack.Count);
            Assert.AreEqual(0, _context.UndoManager.RedoStack.Count);
            Assert.IsFalse(undoRedoBeforeCalledBottom);
            Assert.IsFalse(undoRedoAfterCalledBottom);
            Assert.AreEqual(UndoEditType.Multiple, _context.UndoManager.UndoStack.First().Type);
            Assert.AreEqual(undoRedoElementTop, _context.UndoManager.UndoStack.First().ElementName);
            Assert.AreEqual("4", _context.UndoManager.UndoStack.First().Cause); // 4 item names are effected from this undo action
            Assert.AreEqual(undoRedoElementBottom, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
            Assert.AreEqual(undoRedoElementBottom, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name);

            _context.UndoManager.Undo();
            Assert.IsTrue(undoRedoBeforeCalledBottom);
            Assert.IsTrue(undoRedoAfterCalledBottom);
            Assert.IsTrue(undoRedoBeforeCalledMiddle);
            Assert.IsTrue(undoRedoAfterCalledMiddle);
            Assert.IsTrue(undoRedoBeforeCalledTop);
            Assert.IsTrue(undoRedoAfterCalledTop);

            Assert.AreEqual(descBefore, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description);
            Assert.AreEqual(nameBefore, _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name);
        }


        [TestMethod]
        public void TestCause()
        {
            const string actionName = "actionName";
            string value1 = Guid.NewGuid().ToString("N");
            string value2 = Guid.NewGuid().ToString("N");
            string userstoryName = _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Name;
       
            using (_context.UndoManager.CaptureUndoRedoAction(actionName, null,null))
            {
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = value1;
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].StoryPoints = 100;
                _context.Projects[Resources.Project1Id].Iterations[Resources.Iteration1Id].Stories[Resources.UserStory3Id].Description = value2;
            }
            Assert.AreEqual(actionName, _context.UndoManager.UndoStack.First().ElementName);
            Assert.AreEqual("2", _context.UndoManager.UndoStack.First().Cause);
            _context.UndoManager.Undo();
            _context.UndoManager.DiscardAllEdits();


            using (_context.UndoManager.CaptureUndoRedoAction(actionName, null, null))
            {
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].Description = value1;
                _context.Projects[Resources.Project1Id].Stories[Resources.UserStory1Id].StoryPoints = 100;
            }
            Assert.AreEqual(userstoryName, _context.UndoManager.UndoStack.First().ElementName);
            Assert.IsTrue(_context.UndoManager.UndoStack.First().Cause.Contains(";")); //should contain 2 field name
            _context.UndoManager.Undo();
            _context.UndoManager.DiscardAllEdits();
        
        }

        /// <summary>
        /// Use TestInitialize to run code before running each test .
        /// </summary>
        [TestInitialize]
        public void TestInitialize()
        {
            IDataContext data = DataConnectionFactory.Create(DataAssembly.FromAssembly(typeof(DataContext).Assembly));
            _context = DomainContextFactory.Create(data);
            _context.Connect(
                new SyncDataDispatcher(),
                new ConnectionInformationManager(ConnectionInformation.Empty),
                delegate { },
                Resources.GetProjectTestDataFilePath(TestContext.TestDir));

            _context.Projects[Resources.Project1Id].LoadData(new NullDataImportMonitor());
            _context.Projects[Resources.Project2Id].LoadData(new NullDataImportMonitor());
        }

        /// <summary>
        /// Use TestCleanup to run code after each test has run.
        /// </summary>
        [TestCleanup]
        public void TestCleanup()
        {
            _context.Dispose();
            _context = null;
        }

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}
